package android.tusnotas.util;

import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Log;

import java.util.UUID;

/**
 * Created with IntelliJ IDEA.
 * User: nico
 * Date: 13/08/12
 * Time: 10:25
 * To change this template use File | Settings | File Templates.
 */
public class IdGenerator {

    private Context context;

    public IdGenerator(Context context) {
        this.context = context;
    }

    public String getId(){
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        final String tmDevice, tmSerial, androidId;
        tmDevice = "" + tm.getDeviceId();
        tmSerial = "" + tm.getSimSerialNumber();
        androidId = ""
                + android.provider.Settings.Secure.getString(context.getContentResolver(),
                android.provider.Settings.Secure.ANDROID_ID);

        UUID deviceUuid = new UUID(androidId.hashCode(),
                ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());

        return deviceUuid.toString();
    }
}
